package cc.mrbird.febs.mark.controller;

import cc.mrbird.febs.common.entity.FebsConstant;
import cc.mrbird.febs.common.utils.FebsUtil;
import cc.mrbird.febs.mark.entity.Railway;
import cc.mrbird.febs.mark.service.IRailwayService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Parameter;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.validation.constraints.NotBlank;
import java.util.HashMap;

@Controller("markView")

public class ViewController {

    @Autowired
    private IRailwayService railwayService;

    @GetMapping(FebsConstant.VIEW_PREFIX + "mark/railway")
    @RequiresPermissions("railway:view")
    public String markRailway() {
        return FebsUtil.view("mark/railway/railway");
    }

    @GetMapping(FebsConstant.VIEW_PREFIX + "mark/railway/segwords/{railwayId}")
    @RequiresPermissions("railway:update")
    public String railwaySegwords(@NotBlank(message = "{required}") @PathVariable Long railwayId, Model model) {
        Railway railway = railwayService.getById(railwayId);
        model.addAttribute("railway", railway);
        return FebsUtil.view("mark/railway/segwords");
    }

    @GetMapping(FebsConstant.VIEW_PREFIX + "mark/el/{tag}")
    @RequiresPermissions("railway:view")
    public String markElRailway(@PathVariable String tag,Model model){
        model.addAttribute("tag", tag);
        return FebsUtil.view("mark/el/elMark");
    }

    @GetMapping(FebsConstant.VIEW_PREFIX + "mark/el/elMarkResult/{railwayId}")
    @RequiresPermissions("railway:update")
    public String railwayMarkEl(@NotBlank(message = "{required}") @PathVariable Long railwayId, Model model) {
        Railway railway = railwayService.getById(railwayId);
        model.addAttribute("railway", railway);

        return FebsUtil.view("mark/el/elMarkResult");
    }

    @GetMapping(FebsConstant.VIEW_PREFIX + "mark/question/qaMarkHelp")
    public String qaMarkHelp() {
        return FebsUtil.view("mark/question/qaMarkHelp");
    }

    @GetMapping(FebsConstant.VIEW_PREFIX + "mark/question")
    @RequiresPermissions("railway:view")
    public String qaElRailway() {
        return FebsUtil.view("mark/question/qaMark");
    }

    @GetMapping(FebsConstant.VIEW_PREFIX + "mark/question/qaMarkResult/{railwayId}")
    @RequiresPermissions("railway:update")
    public String railwayMarkQA(@NotBlank(message = "{required}") @PathVariable Long railwayId, Model model) {
        Railway railway = railwayService.getById(railwayId);
        model.addAttribute("railway", railway);

        return FebsUtil.view("mark/question/qaMarkResult");
    }

    @GetMapping(FebsConstant.VIEW_PREFIX + "mark/el/elMarkHelp")
    public String elMarkHelp() {
        return FebsUtil.view("mark/el/elMarkHelp");
    }


    @GetMapping(FebsConstant.VIEW_PREFIX + "mark/railway/operateSegwords")
    public String operateSegwords() {
        return FebsUtil.view("mark/railway/operateSegwords");
    }


    @GetMapping(FebsConstant.VIEW_PREFIX + "system/railway/eximport")
    @RequiresPermissions("railway:view")
    public String eximport() {
        return FebsUtil.view("system/railway/eximport");
    }

    @GetMapping(FebsConstant.VIEW_PREFIX + "system/railway/eximport/result")
    public String eximportResult() {
        return FebsUtil.view("system/railway/eximportResult");
    }

    @GetMapping(FebsConstant.VIEW_PREFIX + "system/railway/inputStuNo")
    @RequiresPermissions("railway:view")
    public String inputStuNo() {
        return FebsUtil.view("system/railway/inputStuNo");
    }
}
